<html>
<head><meta charset="utf-8"><title>Type inference on `const` declarations · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html">Type inference on `const` declarations</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211805123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211805123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211805123">(Sep 30 2020 at 19:00)</a>:</h4>
<p>Is there an actual strong reason that a <code>const</code> can't just infer its type? Or ar least to try an inference and then compile error if it can't do it?</p>



<a name="211805200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211805200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211805200">(Sep 30 2020 at 19:00)</a>:</h4>
<p>If it's just like a grammar issue, could the type be given as <code>_</code> and then that would trigger the inference?</p>



<a name="211811955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211811955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211811955">(Sep 30 2020 at 19:58)</a>:</h4>
<p>Is it perhaps related to the deliberate non-type-inference of function declarations?</p>



<a name="211812044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211812044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211812044">(Sep 30 2020 at 19:58)</a>:</h4>
<p>If it is a top level item, perhaps it makes for good documentation</p>



<a name="211817820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211817820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211817820">(Sep 30 2020 at 20:44)</a>:</h4>
<p>Documentation + a fixed place to have concrete errors point.</p>



<a name="211861263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211861263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211861263">(Oct 01 2020 at 01:55)</a>:</h4>
<p>Yes, AFAIK it's the general principle that items fully specify their types.</p>



<a name="211861279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211861279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211861279">(Oct 01 2020 at 01:55)</a>:</h4>
<p>A type-inferred const is called a macro <span aria-label="smirk" class="emoji emoji-1f60f" role="img" title="smirk">:smirk:</span>                       /s</p>



<a name="211862447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211862447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211862447">(Oct 01 2020 at 02:17)</a>:</h4>
<p>Well, for example, I have a lot of constants like:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">SDL_WINDOW_MAXIMIZED</span>: <span class="nc">SDL_WindowFlags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">SDL_WindowFlags</span><span class="p">(</span><span class="mh">0x00000080</span><span class="p">);</span><span class="w"></span>
</code></pre></div>

<p>And since the type of the expression on the right is fully declared, it seems silly to have to <em>extra</em> declare it on the left too.</p>



<a name="211863550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211863550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211863550">(Oct 01 2020 at 02:41)</a>:</h4>
<p><code>pub const SDL_WINDOW_MAXIMIZED: SDL_WindowFlags = default! { 0: 0x00000080 };</code> <a href="https://internals.rust-lang.org/t/short-enum-variant-syntax-in-some-cases/13113/9?u=scottmcm">with this</a></p>
<p>I think the more serious answer, though, is that the extra noise of the type is negligible compared to the noise of the doc comment, so it doesn't much matter.</p>



<a name="211863637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211863637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211863637">(Oct 01 2020 at 02:43)</a>:</h4>
<p>Especially for a "real" newtype like that.  It annoys me way more in <code>pub const ONE: NonZeroU32 = NonZeroU32::try_from(1).unwrap();</code>, but hopefully we'll get enough const-in-trait to do custom literals nicely one day so it'll just be <code>pub const ONE: NonZeroU32 = 1;</code></p>



<a name="211864382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864382">(Oct 01 2020 at 02:59)</a>:</h4>
<p>I would also be happy with <code>pub const SDL_WINDOW_MAXIMIZED: SDL_WindowFlags = _(0x00000080);</code></p>



<a name="211864394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864394">(Oct 01 2020 at 02:59)</a>:</h4>
<p>I don't really care whether the left or right hand side learns inference, as long as one of them does. :)</p>



<a name="211864460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864460">(Oct 01 2020 at 03:00)</a>:</h4>
<p>There have been a lot of proposals for syntax like <code>_::Variant(...)</code> in places where you know an enum type.</p>



<a name="211864469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864469">(Oct 01 2020 at 03:00)</a>:</h4>
<p>Or <code>_ { foo: bar }</code> in places where you know a struct type.</p>



<a name="211864473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864473">(Oct 01 2020 at 03:00)</a>:</h4>
<p>This seems like one of those places.</p>



<a name="211864485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864485">(Oct 01 2020 at 03:01)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> How would you feel about that approach?</p>



<a name="211864552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864552">(Oct 01 2020 at 03:02)</a>:</h4>
<p>I'm not sure I can explain why, but for some reason <code>_(3)</code> feels bad in a way that <code>_ { x: 3 }</code> doesn't.</p>



<a name="211864566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864566">(Oct 01 2020 at 03:03)</a>:</h4>
<p><code>_(3)</code> reminds me of mir haha</p>



<a name="211864568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864568">(Oct 01 2020 at 03:03)</a>:</h4>
<p>But <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span>  to the general "I want a way to use the type from the context" feeling, <span class="user-mention" data-user-id="239881">@Josh Triplett</span></p>



<a name="211864569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864569">(Oct 01 2020 at 03:03)</a>:</h4>
<p><code>_3  = _2</code></p>



<a name="211864585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864585">(Oct 01 2020 at 03:04)</a>:</h4>
<p>Agreed, as well as older memories of <a href="https://www.boost.org/libs/lambda">https://www.boost.org/libs/lambda</a> (<code>_1 &lt; _2</code>)</p>



<a name="211864645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864645">(Oct 01 2020 at 03:05)</a>:</h4>
<p>Hmm, I suppose one version of this once we have <code>impl const From</code> (or whatever) is just<br>
<code>pub const SDL_WINDOW_MAXIMIZED: SDL_WindowFlags = 0x00000080.into();</code></p>



<a name="211864651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864651">(Oct 01 2020 at 03:05)</a>:</h4>
<p>Good point. :)</p>



<a name="211864658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864658">(Oct 01 2020 at 03:05)</a>:</h4>
<p>(assuming you <em>want</em> to have a From impl)</p>



<a name="211864749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864749">(Oct 01 2020 at 03:07)</a>:</h4>
<p>(True, though for newtypes it's very common to have either <code>From</code> or <code>TryFrom</code>, and if it's more than just a one-field thing I feel like the <code>_</code> forms would look less weird to me.)</p>



<a name="211864760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864760">(Oct 01 2020 at 03:07)</a>:</h4>
<p>A thought that jumped to mind, though it has many problems of its own:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">SDL_WINDOW_MAXIMIZED</span>: <span class="nc">SDL_WindowFlags</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">Self</span><span class="p">(</span><span class="mh">0x00000080</span><span class="p">);</span><span class="w"></span>
</code></pre></div>



<a name="211864910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864910">(Oct 01 2020 at 03:10)</a>:</h4>
<p>It's an interesting thought, but I feel like overloading <code>Self</code> for that would be confusing.</p>



<a name="211864921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864921">(Oct 01 2020 at 03:11)</a>:</h4>
<p>what's wrong with <code>pub const SDL_WINDOW_MAXIMIZED = SDL_WindowFlags(0x00000080);</code>?</p>



<a name="211864932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211864932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211864932">(Oct 01 2020 at 03:11)</a>:</h4>
<p>with the understanding that the type can't be affected by the use, only by the initialization</p>



<a name="211865155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865155">(Oct 01 2020 at 03:16)</a>:</h4>
<p>I guess if it is <code>pub const FOO = function_somewhere();</code> you might be confused about the type of <code>FOO</code> by looking at the source</p>



<a name="211865162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865162">(Oct 01 2020 at 03:16)</a>:</h4>
<p>that just seems like normal type inferrence though? <code>function_somewhere()</code> must always have a fully specified type</p>



<a name="211865166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865166">(Oct 01 2020 at 03:16)</a>:</h4>
<p>Hm, what if <code>function_somewhere() -&gt; impl Trait</code>?</p>



<a name="211865179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865179">(Oct 01 2020 at 03:17)</a>:</h4>
<p>that isn't allowed in constants currently I thought</p>



<a name="211865182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865182">(Oct 01 2020 at 03:17)</a>:</h4>
<p>since you have to know the exact type</p>



<a name="211865196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865196">(Oct 01 2020 at 03:17)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=046af52b946a0ee4bb1b3d30c2b4de40">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=046af52b946a0ee4bb1b3d30c2b4de40</a></p>



<a name="211865197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865197">(Oct 01 2020 at 03:17)</a>:</h4>
<p>well this whole feature is hypothetical</p>



<a name="211865262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865262">(Oct 01 2020 at 03:19)</a>:</h4>
<p>right, I'm saying continue to disallow it</p>



<a name="211865275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865275">(Oct 01 2020 at 03:19)</a>:</h4>
<p>and instead of 'these two features interact to make it not possible', 'remove one of the features and make the other explicitly forbidden'</p>



<a name="211865333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865333">(Oct 01 2020 at 03:20)</a>:</h4>
<p>I think the sense in which this is not normal type inference is that you can get cross crate inference</p>



<a name="211865341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865341">(Oct 01 2020 at 03:20)</a>:</h4>
<p>although I think all this came up already for async fns</p>



<a name="211865670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211865670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211865670">(Oct 01 2020 at 03:29)</a>:</h4>
<p>Yeah, Josh, and goes particularly poorly for associated consts anyway.</p>



<a name="211867077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211867077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211867077">(Oct 01 2020 at 04:02)</a>:</h4>
<p>Another common case is more like this:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="n">DISPCNT_VAL</span>: <span class="nc">DisplayControlSetting</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DisplayControlSetting</span>::<span class="n">new</span><span class="p">()</span><span class="w"></span>
<span class="w">  </span><span class="p">.</span><span class="n">with_video_mode</span><span class="p">(</span><span class="n">VideoMode</span>::<span class="n">_3</span><span class="p">)</span><span class="w"></span>
<span class="w">  </span><span class="p">.</span><span class="n">with_display_bg2</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span><span class="w"></span>
</code></pre></div>

<p>And you can have any sort of more complex expression, a block, a const fn, etc.</p>
<p>Essentially as const eval gets better, this particular little case will nag more and more i expect.</p>



<a name="211867247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211867247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211867247">(Oct 01 2020 at 04:06)</a>:</h4>
<p>I think with more complex RHSs like that omitting the type would be worse.</p>



<a name="211867277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211867277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211867277">(Oct 01 2020 at 04:07)</a>:</h4>
<p>Change it to using a builder and it would look almost the same but the type wouldn't be named anywhere any more...</p>



<a name="211867279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211867279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211867279">(Oct 01 2020 at 04:07)</a>:</h4>
<p>Especially if you might accidentally end up with <code>&amp;mut Foo</code> instead of <code>Foo</code>.</p>



<a name="211867340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211867340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211867340">(Oct 01 2020 at 04:09)</a>:</h4>
<p>And I think I saw someone starting on <code>const{}</code> blocks, so <code>let foo = const { isplayControlSetting::new().with_video_mode(VideoMode::_3);</code> will start to be available for the non-item uses soon hopefully.</p>



<a name="211868011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211868011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211868011">(Oct 01 2020 at 04:24)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> well specifically <code>&amp;mut T</code> you'd never get at least, but i suppose there is the potential concern of alternative types of other forms.</p>



<a name="211900286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211900286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211900286">(Oct 01 2020 at 12:16)</a>:</h4>
<blockquote>
<p>well specifically <code>&amp;mut T</code> you'd never get at least</p>
</blockquote>
<p>Why not?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Builder</span><span class="p">;</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Builder</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">alpha</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="bp">Self</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="bp">self</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">beta</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="bp">Self</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="bp">self</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">build</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">i32</span> <span class="p">{</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">const</span><span class="w"> </span><span class="n">DEMO</span><span class="w">  </span><span class="o">=</span><span class="w"> </span><span class="n">Builder</span><span class="p">.</span><span class="n">alpha</span><span class="p">().</span><span class="n">beta</span><span class="p">();</span><span class="w"> </span><span class="c1">// Oops forgot to call `.build()`</span>
</code></pre></div>



<a name="211901766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211901766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211901766">(Oct 01 2020 at 12:31)</a>:</h4>
<p>That seems like a problem anywhere though, the solution I use is to put must_use on the builder.</p>



<a name="211902639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211902639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211902639">(Oct 01 2020 at 12:38)</a>:</h4>
<p>Doesn't seem like a good idea for that style of builder, which is usually optimized for conditional calls:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Builder</span><span class="p">;</span><span class="w"></span>
<span class="k">if</span><span class="w"> </span><span class="n">something</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">b</span><span class="p">.</span><span class="n">alpha</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="n">b</span><span class="p">.</span><span class="n">beta</span><span class="p">().</span><span class="n">build</span><span class="p">()</span><span class="w"></span>
</code></pre></div>



<a name="211902967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211902967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211902967">(Oct 01 2020 at 12:41)</a>:</h4>
<p>that wouldn't warn I don't think</p>



<a name="211903349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211903349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211903349">(Oct 01 2020 at 12:44)</a>:</h4>
<p>ah hmm this doesn't work anyway because it returns &amp;mut instead of self <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2570fb434658e8cf857237352f662080">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2570fb434658e8cf857237352f662080</a></p>



<a name="211913552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211913552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211913552">(Oct 01 2020 at 13:56)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> an intermediate value in the chain could be &amp;mut but the final value cannot be</p>



<a name="211914552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211914552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211914552">(Oct 01 2020 at 14:02)</a>:</h4>
<p>That is: a const declaration can't be &amp;mut T, ever</p>



<a name="211915016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/211915016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#211915016">(Oct 01 2020 at 14:05)</a>:</h4>
<p><code>&amp;mut Zst</code> could be const, but that's philosophical I guess (note that I think <code>&amp;mut []</code> is const under certain circumstances)</p>



<a name="212008651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212008651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212008651">(Oct 02 2020 at 06:12)</a>:</h4>
<p>Ah, looks like the current <code>&amp;ZstLiteral</code> =&gt; <code>&amp;*(alignof(T) as *const _)</code> is in codegen, not mir-time, <a href="https://github.com/rust-lang/rust/pull/63635">https://github.com/rust-lang/rust/pull/63635</a></p>



<a name="212039408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212039408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212039408">(Oct 02 2020 at 07:10)</a>:</h4>
<p>yes, there were concerns about that not being actually legal to do in case of <code>let x = ZstLiteral; let y = &amp;x;</code> and I was unable to figure out whether I can guarantee that not to accidentally also get optimized</p>



<a name="212220358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212220358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212220358">(Oct 04 2020 at 12:07)</a>:</h4>
<p>Is the desire to add type inference to const because it's a pain to write, for readability, or both?</p>
<p>If it's just for writing purposes I wonder to which degree Rust-Analyzer /rustfix could help</p>



<a name="212222984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212222984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212222984">(Oct 04 2020 at 13:17)</a>:</h4>
<p>I think some of it is array lengths changing but actually being irrelevant beyond having them statically and not as a slice</p>



<a name="212224343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212224343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212224343">(Oct 04 2020 at 13:55)</a>:</h4>
<p><code>const BLA: _ = &lt;something&gt;;</code> already tells you the right type in the error message, but it doesn't seem to be an automatically applicable suggestion</p>



<a name="212237338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212237338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212237338">(Oct 04 2020 at 19:18)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> See my comment about <code>impl usize</code> (strawman syntax) over in <a href="https://github.com/rust-lang/rfcs/pull/2545#issuecomment-661305546">https://github.com/rust-lang/rfcs/pull/2545#issuecomment-661305546</a> for that problem.</p>



<a name="212267894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212267894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212267894">(Oct 05 2020 at 07:48)</a>:</h4>
<p>ooh that is a very neat way to solve this</p>



<a name="212426769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Type%20inference%20on%20%60const%60%20declarations/near/212426769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Type.20inference.20on.20.60const.60.20declarations.html#212426769">(Oct 06 2020 at 13:27)</a>:</h4>
<p>this would be a great topic to add as a "design summary" to the lang team website btw &lt;3</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>